/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：太平金科-基础组件封装层-登录通-缺省实现
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taipingframework.boot.dlt.autoconfigure;

import com.taiping.dlt.pojo.properties.DltProperty;
import com.taiping.dlt.scanner.DltDaoScanner;
import com.taiping.dlt.scanner.DltManagerScanner;
import com.taiping.dlt.scanner.DltServiceScanner;
import com.taipingframework.boot.dlt.filters.DltFilter;
import com.taipingframework.boot.dlt.scanner.DltWebScanner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import reactor.core.publisher.Flux;

@Slf4j
@Configuration(proxyBeanMethods = false)
//@EnableConfigurationProperties(value = {DltProperty.class})
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@ConditionalOnClass({Flux.class})

@Import({DltWebScanner.class, DltServiceScanner.class, DltManagerScanner.class, DltDaoScanner.class})
public class DltWebFluxAutoConfiguration {

    /**
     * 登录通配置
     */
    @Bean
    @ConfigurationProperties("application.dlt")
    public DltProperty dltProperty() {
        return new DltProperty();
    }

    /**
     * 登录通过滤器：过滤特殊字符
     */
    @Bean
    @ConditionalOnProperty(prefix = "application.flux.filter", name = {"enable-dlt-filter"}, havingValue = "true", matchIfMissing = true)
    public DltFilter dltFilter() {
        return new DltFilter();
    }

}
